﻿<phone:PhoneApplicationPage
                            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                            xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
                            xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
                            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                            xmlns:cmd="clr-namespace:MvvmLight.Command;assembly=MvvmLight"
                            xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
                            xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"  
                            xmlns:turnstile="clr-namespace:AccountHelper.UserControls.Turnstile"
                            xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
                            x:Class="AccountHelper.View.MainView"
                            FontFamily="{StaticResource PhoneFontFamilyNormal}"
                            FontSize="{StaticResource PhoneFontSizeNormal}"
                            Foreground="{StaticResource PhoneForegroundBrush}"
                            SupportedOrientations="PortraitOrLandscape"
                            Orientation="Portrait"
                            mc:Ignorable="d"
                            d:DesignWidth="480"
                            d:DesignHeight="800"
                            shell:SystemTray.IsVisible="False"
                            DataContext="{Binding MainVM, Source={StaticResource Locator}}" 
                            >
    <phone:PhoneApplicationPage.Resources>
        <DataTemplate x:Key="TurnstileItemTemplate">
            <Grid Background="{StaticResource PhoneAccentBrush}"  Margin="10" Width="150" Height="150">
                <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
                    <Border BorderBrush="Gray">
                        <Image Width="62" Height="62"  Source="{Binding IcoUrl}" Stretch="Fill" />
                    </Border>
                    <TextBlock Text="{Binding MenuName}" 
                                           Foreground="White"
                                           Margin="3"
                                           FontSize="24" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                </StackPanel>
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="MouseLeftButtonDown">
                        <cmd:EventToCommand Command="{Binding MainVM.MenuCommand,Source={StaticResource Locator}}" 
                                            CommandParameter="{Binding Type}"/>
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </Grid>
        </DataTemplate>
        
        <Style x:Key="S_ListBoxItem" TargetType="ListBoxItem">
            <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        </Style>
    </phone:PhoneApplicationPage.Resources>
	<Grid x:Name="LayoutRoot">
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto" />
			<RowDefinition Height="*" />
		</Grid.RowDefinitions>

		<StackPanel x:Name="TitlePanel"
		            Grid.Row="0"
		            Margin="24,24,0,12"/>

        <Grid x:Name="ContentGrid"
		      Grid.Row="1" Margin="0,0,0,0">
            <controls:Panorama Title="Account Helper" Foreground="White" SelectionChanged="accountPanorama_SelectionChanged" x:Name="accountPanorama" FontFamily="Segoe WP">
                <controls:Panorama.Background>
                    <ImageBrush ImageSource="/Images/backgound.jpg" />
                </controls:Panorama.Background>
            

                <!--Panorama Menu-->
                <controls:PanoramaItem x:Name="piMenu" Header="">
                    <Grid Margin="0,-30,0,0">
                        <ScrollViewer >
                            <turnstile:Turnstile ItemsSource="{Binding MenuList}" ItemTemplate="{StaticResource TurnstileItemTemplate}" 
                              x:Name="tilesControl" VerticalAlignment="Top" 
                              d:LayoutOverrides="VerticalAlignment">
                                <turnstile:Turnstile.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <toolkit:WrapPanel />
                                    </ItemsPanelTemplate>
                                </turnstile:Turnstile.ItemsPanel>
                            </turnstile:Turnstile>
                        </ScrollViewer>
                    </Grid>
                </controls:PanoramaItem>

                <!--Panorama Cost-->
                <controls:PanoramaItem x:Name="piCost" Foreground="White">
                    <controls:PanoramaItem.Header>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="支出" />
                            <Image Source="/Images/newCharge.png" Margin="160,0,0,0">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="MouseLeftButtonDown">
                                        <cmd:EventToCommand Command="{Binding MainVM.NewFromImageCommand,Source={StaticResource Locator}}" CommandParameter="cost" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </Image>
                        </StackPanel>
                    </controls:PanoramaItem.Header>
                    <Grid>
                        <ListBox ItemContainerStyle="{StaticResource S_ListBoxItem}" x:Name="lbxCosts" ItemsSource="{Binding CostsMoney}" ItemTemplate="{StaticResource DT_Charges_List}"  />
                    </Grid>
                </controls:PanoramaItem>

                <!--Panorama Charge-->
                <controls:PanoramaItem x:Name="piCharge" Foreground="White">
                    <controls:PanoramaItem.Header>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="收入" />
                            <Image Source="/Images/newCharge.png" Margin="160,0,0,0">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="MouseLeftButtonDown">
                                        <cmd:EventToCommand Command="{Binding MainVM.NewFromImageCommand,Source={StaticResource Locator}}" CommandParameter="charge" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </Image>
                        </StackPanel>
                    </controls:PanoramaItem.Header>
                    <Grid>
                        <ListBox ItemContainerStyle="{StaticResource S_ListBoxItem}" x:Name="lbxCharges" ItemsSource="{Binding ChargesMoney}" ItemTemplate="{StaticResource DT_Charges_List}" />
                    </Grid>
                </controls:PanoramaItem>

                <!--Panorama Account-->
                <controls:PanoramaItem x:Name="piProfile" Header="个人账户" Foreground="White">
                    <Grid>
                        <ScrollViewer>
                            <Grid>
                                <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="8,8,0,0" VerticalAlignment="Top" d:LayoutOverrides="Width, Height">
                                    <Image Height="152" Margin="0,0,0,0" Source="{Binding ProfileImage}"/>
                                    <StackPanel Margin="40,0,0,0">
                                        <TextBlock  Text="{Binding CurrentUser.UserName}" FontSize="36" Margin="24,0,0,0"/>
                                        <Button Content="Pin To Start" BorderThickness="0" Command="{Binding MainVM.PinToStartCommand,Source={StaticResource Locator}}" />
                                    </StackPanel>
                                    
                                </StackPanel>
                                <Grid Margin="0,168,0,0">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="0.3*"/>
                                        <RowDefinition Height="0.3*"/>
                                        <RowDefinition Height="0.4*"/>
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="0.5*"/>
                                        <ColumnDefinition Width="0.5*"/>
                                    </Grid.ColumnDefinitions>
                                    <Border BorderBrush="Black" BorderThickness="0" Margin="5,5,10,10">
                                        <Border.Background>
                                            <SolidColorBrush Color="{StaticResource PhoneAccentColor}"/>
                                        </Border.Background>
                                        <StackPanel>
                                            <TextBlock Text="支出" Foreground="White"/>
                                            <TextBlock Text="{Binding CurrentUser.CurCost}" />
                                        </StackPanel>
                                    </Border>
                                    <Border BorderBrush="Black" BorderThickness="0" Margin="5,5,5,10" Grid.Column="1" >
                                        <Border.Background>
                                            <SolidColorBrush Color="{StaticResource PhoneAccentColor}"/>
                                        </Border.Background>
                                        <StackPanel>
                                            <TextBlock Text="收入" Foreground="White"/>
                                            <TextBlock Text="{Binding CurrentUser.CurCharge}" />
                                        </StackPanel>
                                    </Border>
                                    <Border BorderBrush="Black" BorderThickness="0" Margin="5,5,5,10" Grid.Row="1" Grid.ColumnSpan="2"  toolkit:TiltEffect.IsTiltEnabled="True">
                                        <Border.Background>
                                            <SolidColorBrush Color="{StaticResource PhoneAccentColor}"/>
                                        </Border.Background>
                                        <StackPanel Margin="0,0,0,12" HorizontalAlignment="Left">
                                            <TextBlock Text="合计"/>
                                            <TextBlock Text="{Binding CurrentUser.CurTotal}"/>
                                            <TextBlock Text="{Binding CurrentUser.CurTotal,Converter={StaticResource numberToChsConverter}}"/>
                                        </StackPanel>
                                    </Border>
                                </Grid>
                            </Grid>
                        </ScrollViewer>
                    </Grid>
                </controls:PanoramaItem>
            </controls:Panorama>
        </Grid>
    </Grid>
    
</phone:PhoneApplicationPage>